﻿<%@ Page Language="C#" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<% 
    string root = Request.Params["node"];
    OleDbConnection conn = null;
try
{
    conn = DBOp.DbConn;
    OleDbCommand comm = conn.CreateCommand();
    string index = "";
    if (root == "root1")
    {
        index = "2";
        comm.CommandText = "select distinct 城区名称 from JZ";
    }
    else if (root.EndsWith("2"))
    {
        index = "3";
        comm.CommandText = "select distinct 街道名 from jz where 城区名称 = '" + root.TrimEnd('2') + "'";
    }
    else if(root.EndsWith("3"))
    {
        index = "4";
        comm.CommandText = "select distinct 社区名 from jz where 街道名 = '" + root.TrimEnd('3') + "'";
    }
    System.Data.DataTable dt = new System.Data.DataTable();
    OleDbDataAdapter oda = new OleDbDataAdapter(comm);    
    oda.Fill(dt);
    %>[<%
           int i = 0;
    foreach (DataRow dr in dt.Rows)
    {
        i++;
        string text = dr[0].ToString();
        %>
                    {
                        text: '<%=text %>',
                        id:'<%=text + index %>'
                        
                        <%=index == "4" ? ",checked:false,leaf:true" : ""%>
                    }<%=i == dt.Rows.Count?"":"," %>           
                    <%
    }
    %>]<%
}
catch (Exception ex) { 
    %><%=ex.Message %><%
}
    finally{
    if(conn != null)
    conn.Close();} %>
